home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / pascal / tvtool2.zip / TVTYPE.INT < prev    next >
Text File  |  1993-07-20  |  3KB  |  154 lines

  1. UNIT TvType;
  2. {$B+}
  3. {$X+}
  4. {$V-}
  5.  
  6. {$I TVDEFS.INC}
  7.  
  8. INTERFACE
  9.  
  10. USES
  11.   Dos,
  12.   Objects;
  13.  
  14.  
  15. CONST
  16.   DateSlash : Char = '/';
  17.  
  18.  
  19. CONST
  20.   BaseYear  : Word = 1900;
  21.  
  22.  
  23. TYPE
  24.   TbxFrameArray = Array[1..8] of Char;
  25.  
  26.  
  27.   PbxCharArray  = ^TbxCharArray;
  28.   TbxCharArray  = Array[0..$FFE0] of Char;
  29.  
  30.  
  31.   PbxByteArray  = ^TbxByteArray;
  32.   TbxByteArray  = Array[0..$FFE0] of Byte;
  33.  
  34.  
  35.   TbxCharSet    = Set of Char;
  36.   TbxByteSet    = Set of Byte;
  37.  
  38.  
  39.   TbxLong    = record
  40.     Low, High : Word;
  41.   end;
  42.  
  43.  
  44.   { Record passed between two TbxPairedListBox objects }
  45.   PbxItemRec = ^TbxItemRec;
  46.   TbxItemRec = record
  47.     Owner,Item : Pointer;
  48.   end;
  49.  
  50.  
  51.   { DATE TYPES }
  52.  
  53.   TbxDateSt   = String[12]; {"mm/dd/yyyy", etc.}
  54.  
  55.  
  56.   { Record for TbxDate GetData and SetData }
  57.   TbxDateRec  = record
  58.     Day   : Byte;
  59.     Month : Byte;
  60.     Year  : Word;
  61.   end;
  62.  
  63.  
  64.   PbxDate = ^TbxDate;
  65.   TbxDate = Object(TObject)
  66.     Day   : Byte;
  67.     Month : Byte;
  68.     Year  : Word;
  69.  
  70.     Constructor Init(D : Byte; M : Byte; Y : Word);
  71.     Constructor Load(var S : TStream);
  72.     Function    Compare(var ADate : PbxDate): Integer;
  73.     Function    DateString(Picture : TbxDateSt): TbxDateSt;
  74.     Function    DaysInMonth: Word;
  75.     Procedure   ExtractDate(Picture : TbxDateSt;
  76.                             ADateSt : TbxDateSt);
  77.     Procedure   GetData(var Rec);
  78.     Function    GetDay: Byte;
  79.     Function    GetMonth: Byte;
  80.     Function    GetYear: Word;
  81.     Function    LeapYear: Boolean;
  82.     Procedure   SetData(var Rec);
  83.     Procedure   SetDay(D : Byte);
  84.     Procedure   SetMonth(M : Byte);
  85.     Procedure   SetToday;
  86.     Procedure   SetYear(Y : Word);
  87.     Procedure   Store(var S : TStream);
  88.     Function    Valid: Boolean;                           Virtual;
  89.     private
  90.     Function    FourDigitYear(Y : Word): Word;
  91.   end;
  92.  
  93.  
  94. CONST
  95.   MonthString : Array[1..12] of string[9] =
  96.     (
  97.     'January',
  98.     'February',
  99.     'March',
  100.     'April',
  101.     'May',
  102.     'June',
  103.     'July',
  104.     'August',
  105.     'September',
  106.     'October',
  107.     'November',
  108.     'December'
  109.     );
  110.  
  111. CONST
  112.   DayString : Array[1..7] of string[9] =
  113.     (
  114.     'Sunday',
  115.     'Monday',
  116.     'Tuesday',
  117.     'Wednesday',
  118.     'Thursday',
  119.     'Friday',
  120.     'Saturday'
  121.     );
  122.  
  123.  
  124. Function IsLeapYear(Year : Word): Boolean;
  125.  
  126. Function DaysInMonth(Date : TbxDateRec): Word;
  127.  
  128. Function CompareDate(Date1 : TbxDateRec;
  129.                      Date2 : TbxDateRec): Integer;
  130.  
  131. Function DateToDateString(Date    : TbxDateRec;
  132.                           Picture : TbxDateSt): TbxDateSt;
  133.  
  134. Procedure ExtractDateFromString(var Date    : TbxDateRec;
  135.                                     Picture : TbxDateSt;
  136.                                     ADateSt : TbxDateSt);
  137.  
  138.  
  139. { TvType registration procedure }
  140.  
  141. Procedure RegisterTVType;
  142.  
  143.  
  144. { Stream Registration Records }
  145.  
  146. CONST
  147.   RbxDate: TStreamRec = (
  148.     ObjType : 5050;
  149.     VmtLink : Ofs(TypeOf(TbxDate)^);
  150.     Load    : @TbxDate.Load;
  151.     Store   : @TbxDate.Store
  152.   );
  153.  
  154.